package huawei.bfs;

import treenode.TreeNode;

/**
 *
 */
public class J101 {
    public static void main(String[] args){
        TreeNode node=TreeNode.create(1,2,3);
        System.out.println(isSymmetric(node));
    }
    public static boolean isSymmetric(TreeNode root) {
        if(root==null){
            return true;
        }
        return isSy(root.left,root.right);
    }
    private static boolean isSy(TreeNode left, TreeNode right){
        if(left==null&&right==null){
            return true;
        }
        if(left==null||right==null){
            return false;
        }
        if(left.val!=right.val){
            return false;
        }
        return isSy(left.left,right.right)&&isSy(left.right,right.left);
    }
}
